<% content_for :head do -%>
  <%#= javascript_include_tag "admin/index_grid" %>
<% end %>

<% content_for :right_side_bar do %>
  <div class='admin_filters'>
    <%= form_tag admin_shopping_products_path, method: 'get', :id => "products_search" do %>
      <p>
        <ul class=' search_boxes'>
          <li><%= label_tag 'Name' %> <%= text_field_tag :name, params[:name] %></li>
          <li><%= label_tag 'Product Type' %>
              <%= select_tag "product_type_id", options_from_collection_for_select(product_types, "id", "name"), { include_blank: true, class: 'auto_width'} %>
          </li>
        </ul>
        <div style='text-align:center'>
          <%= submit_tag "Search", name: nil, class: 'button red-button alert' %>
        </div>
      </p>
      <div id="order_hidden">
        <%= hidden_field_tag :direction, params[:direction] %>
        <%= hidden_field_tag :sort, params[:sort] %>
      </div>
    <% end %>
    <div class='clearfix'></div>
  </div>
<% end %>

<h2> Products </h2>

<div id="admin_shopping_products_page_wrapper">
  <div id="admin_shopping_products_grid_wrapper" class='column pretty_table'>
      <table class='hover'>
        <thead>
        <tr class='odd'>
            <th class='column1_header'><%= sortable "name" %></th>
            <th>Available</th>
            <th><%= 'Product Type' %></th>
            <th> Price Range </th>
        </tr>
        </thead>
        <% @products.each do |product| %>
          <tr class='<%= cycle("odd", "")%>'>
            <td><%= link_to product.name, edit_admin_shopping_product_path(product) %></td>
            <td><%=  product.available? ? 'Yes' : 'No' %></td>
            <td><%=  product.product_type.name %></td>
            <td><%= product.display_price_range %></td>
          </tr>
        <% end %>
      </table>

    <%= will_paginate @products %>

  </div>
</div>
